import request from '@/utils/request'

export default {
    getPermissionsList(searchModel) {
        return request({
            url: '/permissions',
            method: 'get',
            params:{
                
            }
        });
    },
    getPermissionsById(id){
        return request({
            url: '/permissions/' + id,
            method: 'get',
            params:{
                
            }
        });
    },
    getPermissionsArray(){
        return request({
            url: '/permissionsNoTree/',
            method: 'get',
            params:{
                
            }
        });
    },
    savePermissions(permissions){
        if(permissions.id == null || permissions.id == undefined){
            return this.addPermissions(permissions);
        }
        return this.updatePermissions(permissions);
    },

    updatePermissions(permissions){
        return request({
            url:'/permissions/'+permissions.id,
            method: 'post',
            params: {
                name:permissions.name,
                pid:permissions.pid,
            }
        })
    },
    addPermissions(permissions){
        return request({
            url: '/permissions',
            method: 'post',
            params:{
                name:permissions.name,
                pid:permissions.pid,
            }
        });
    },

    deletePermissions(id){
        return request({
            url: '/permissions/delete/'+id,
            method: 'post',
            params:{
                
            }
        });
    }


    
}